# Contributor: ScrumpyJack <scrumpyjack@st.ilet.to>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=fltk
pkgver=1.3.9
pkgrel=0
pkgdesc="A cross-platform C++ GUI toolkit"
url="https://www.fltk.org/"
arch="all"
options="!check"  # No test suite.
license="LGPL-2.0-only WITH FLTK-exception"
depends_dev="
	cairo-dev
	libjpeg-turbo-dev
	libpng-dev
	libx11-dev
	libxext-dev
	libxft-dev
	libxinerama-dev
	mesa-dev
	"
makedepends="
	$depends_dev
	cmake
	samurai
	"
subpackages="
	$pkgname-doc
	$pkgname-dev
	$pkgname-fluid
	libfltk
	libfltk_cairo
	libfltk_forms
	libfltk_gl
	libfltk_images
	"
source="https://www.fltk.org/pub/fltk/$pkgver/fltk-$pkgver-source.tar.gz"

build() {
	export CFLAGS="$CFLAGS -flto=auto"
	export CXXFLAGS="$CXXFLAGS -flto=auto"

	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DOPTION_CAIRO=ON \
		-DOPTION_CAIROEXT=ON \
		-DOPTION_BUILD_SHARED_LIBS=ON \
		-DFLTK_BUILD_TEST=OFF

	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	# remove static libs
	rm "$pkgdir"/usr/lib/*.a

	mkdir -p "$pkgdir"/usr/lib/cmake/
	mv "$pkgdir"/usr/share/fltk/ "$pkgdir"/usr/lib/cmake/
}

fluid() {
	pkgdesc="Fast Light User Interface Designer"
	depends=

	amove usr/bin
	amove usr/share/applications
	amove usr/share/icons
	amove usr/share/mime
}

libfltk() {
	amove usr/lib/libfltk.so.*
}

libfltk_cairo() {
	amove usr/lib/libfltk_cairo.so.*
}

libfltk_forms() {
	amove usr/lib/libfltk_forms.so.*
}

libfltk_gl() {
	amove usr/lib/libfltk_gl.so.*
}

libfltk_images() {
	amove usr/lib/libfltk_images.so.*
}

sha512sums="
d6766faed7a8c35da0189dead6c5aaaa07ceca8f899e824bf3ce0c5bb125dad801c073d771bb5b8998a8d9239eebeaf8ff9a237472565971a07ccf67b94e90d8  fltk-1.3.9-source.tar.gz
"
